/**
 * JAVACC DEMO 1.0
 * @copy right dwusoft company All rights reserved. 
 * @Package com.apache.bid.service.cacheplugins  
 */
package com.apache.bid.service.cacheplugins;

import com.apache.api.manager.PluginConnector;
import com.apache.api.vo.ParamsVo;
import com.apache.api.vo.ResultEntity;
import com.apache.bid.common.WbdToolsUtil;
import com.apache.bid.entity.BidApply;
import com.apache.bid.manager.BidApplyManager;
import com.apache.cache.util.Validator;

/**
 * description:  修改受让申请信息
 * @author Hou Dayu 创建时间：2016-3-23  
 * 
 */
public class EditApplyPluginImpl implements PluginConnector {

	private BidApplyManager bidApplyManager;

	/**
	 * TODO 简单描述该方法的实现功能（可选）.  
	 * @see com.zbxsoft.api.manager.PluginConnector#execute(com.zbxsoft.api.vo.ParamsVo)  
	 */
	public Object execute(ParamsVo param) throws Exception {
		BidApply apply = new BidApply();
		ResultEntity entity = new ResultEntity();
		String methodKey = String.valueOf(param.getParams("MethodKey"));
		if (Validator.isNull(methodKey)) {
			apply = (BidApply) WbdToolsUtil.getInstance().convert2Bean(param.getParams(), apply);
			if (Validator.isNull(apply.getApplyId())) {
				entity.setResult("false");
				entity.setMessage("缺少方法参数,方法执行失败");
			} else {
				ParamsVo<BidApply> vo = new ParamsVo<BidApply>();
				vo.setObj(apply);
				boolean mark = bidApplyManager.editInfo(vo);
				entity.setResult("true");
				entity.setEntity(mark);
				entity.setMessage("操作成功");
			}
		} else {
			String applyId = Validator.getDefaultStr(param.getInfoId(), String.valueOf(param.getParams("infoId")));
			String status = String.valueOf(param.getParams("status"));
			ParamsVo<BidApply> vo = new ParamsVo<BidApply>();
			vo.setParams("status", status);
			vo.setInfoId(applyId);
			vo.setMethodKey(methodKey);
			boolean mark = bidApplyManager.editInfo(vo);
			entity.setResult("true");
			entity.setEntity(mark);
			entity.setMessage("操作成功");
		}
		return entity;
	}

	public void setBidApplyManager(BidApplyManager bidApplyManager) {
		this.bidApplyManager = bidApplyManager;
	}

}
